package com.gxa.xiaoucomeshome.service.impl;

import com.gxa.xiaoucomeshome.mapper.UserMapper;
import com.gxa.xiaoucomeshome.pojo.Agree;
import com.gxa.xiaoucomeshome.pojo.Order;
import com.gxa.xiaoucomeshome.pojo.User;
import com.gxa.xiaoucomeshome.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User selectByPhone(String phone) {
        User user = userMapper.selectByPhone(phone);
        return user;
    }

    @Override
    public void insert(String name,String phone,String pwd) {
       userMapper.insert(name,phone,pwd);
    }

    @Override
    public Integer selectStateByWait(Integer uid) {
        return userMapper.selectStateByWait(uid);
    }

    @Override
    public Integer selectStateByRunning(Integer uid) {
        return userMapper.selectStateByRunning(uid);
    }

    @Override
    public Integer selectStateByFalse(Integer uid) {
        return userMapper.selectStateByFalse(uid);
    }

    @Override
    public Integer selectStateBySuccess(Integer uid) {
        return userMapper.selectStateBySuccess(uid);
    }

    @Override
    public List<Map<String,Object>> selectOrderListByWait(Integer uid){
        List<Map<String,Object>> maps = userMapper.selectOrderListByWait(uid);
        return maps;
    }
    @Override
    public List<Map<String,Object>> selectOrderListByRunning(Integer uid){
        List<Map<String,Object>> maps = userMapper.selectOrderListByRunning(uid);
        return maps;
    }
    @Override
    public List<Map<String,Object>> selectOrderListBySuccess(Integer uid){
        List<Map<String,Object>> maps = userMapper.selectOrderListBySuccess(uid);
        return maps;
    }
    @Override
    public List<Map<String,Object>> selectOrderListByFalse(Integer uid){
        List<Map<String,Object>> maps = userMapper.selectOrderListByFalse(uid);
        return maps;
    }

    @Override
    public Map<String,Object> selectByOrder_id(String id) {
        return userMapper.selectByOrder_Id(id);
    }

    @Override
    public List<Map<String, Object>> selectAllOrder(Integer uid, String startTime, String endTime,Integer code) {

        List<Map<String, Object>> maps = userMapper.selectAllByUid(uid,startTime,endTime,code);
        return maps;

    }
    @Override
    @Transactional
    public void insertOrder( String order_id, Integer site_id, Integer address_id, Integer uid,
                             Date commitDate,String img1,String img2) {
        userMapper.insertOrder(order_id,site_id,address_id,uid,img1,img2);
        userMapper.insertOrderIdAndTime(order_id,commitDate);
        userMapper.insertOrderIdInDetail(order_id);
    }

    @Override
    public List<Map<String, Object>> selectOrderById(String order_id) {
        List<Map<String, Object>> maps = userMapper.selectOrderById(order_id);
        return maps;
    }

    @Override
    public List<Agree> selectAgree() {
        return userMapper.selectAgree();
    }

    @Override
    public Order selectByOrder_state(Integer uid) {
        return userMapper.selectByOrder_state(uid);
    }

}
